package com.tool_stdy.thread;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by yan_li on 2018/4/5/005.
 */
public class ReentrantLockTest {

    Lock lock = new ReentrantLock();

    public void testDo1() {
        lock.lock();
        System.out.println("testDo1");
        testDo2();
        lock.unlock();
    }

    public void testDo2() {
        lock.lock();
        System.out.println("testDo2");
        lock.unlock();
    }

    public static void main(String[] args) {
        final ReentrantLockTest test = new ReentrantLockTest();
        new Thread(new Runnable() {
            @Override
            public void run() {
                test.testDo1();
            }
        }).start();


    }

}
